home *** CD-ROM | disk | FTP | other *** search
- {>Pas.testtail }
- program testtail(output);
- { Program with PROCEDURE to read the command line
- Author I M Smith April 11th 1989 }
-
- const
- stringlength = 255;
-
- type
- strings = packed array[1..stringlength] of char;
-
- var
- command : strings;
-
- procedure getcommandline (var command : strings);
- const
- r0 = 0; { Register 0 }
- r4 = 4; { Register 4 }
- OS_GetEnv = 16_10; { SWI number }
-
- type
- stringptr = ^strings;
-
- var
- sptr : stringptr;
- a0,i : integer;
-
- begin
- a0 := address(sptr); { sptr can hold the address of a string }
- *LDR_R4,a0; { Load register 4 with address of sptr }
- *SWI_OS_GetEnv; { Call the SWI to read the command tail }
- *STR_R0,[R4]; { Store the contents of R0, which is the
- address of the command tail string, in the
- location whose address is in R4. R4 contains
- the address of sptr. SO sptr contains the
- address of the command tail string }
-
- command := sptr^; { This copies the string pointed to by sptr }
-
- i := 1; { This finds the terminator CHR(0) }
- while command[i] <> chr(0) do
- i := i+1;
- while i < stringlength do { Pad the rest of the string with ' ' }
- begin
- i := i+1;
- command[i] := ' ';
- end;
- end;
-
- begin
- getcommandline(command);
- writeln(command)
-
- { You will need to add a call to a Pascal routine here to extract the
- parameters from the command tail. Something like GetParameter(Command,
- n), where n is an integer, will do. This will return a string and if
- numbers, whether INTEGER or REAL are part of the tail, then you will
- need to use conversion routines. }
- end.
-